<template>
	<view>
		<view class="wen">温馨提示：该功能仅会员才能使用！</view>

		<view class="box">
			<view class="cu-form-group">
				<view class="title">查询方式</view>
				<picker @change="PickerChange" :value="index" :range="picker">
					<view class="picker">
						{{picker[index]}}
					</view>
				</picker>
			</view>
			<view class="cu-bar search bg-white margin-top">
				<view class="search-form round">
					<text class="cuIcon-search"></text>
					<input :adjust-position="false" type="text" placeholder="查询信息" confirm-type="search" v-model="info"></input>
				</view>
				<view class="action">
					<button class="cu-btn bg-green shadow-blur round" @click="cx">查询</button>
				</view>
			</view>
		</view>

		<view v-if="!caxun" style="margin-top: 5%;">

			<!-- 	<view style="text-align: center;">查询结果： </view>
		<view style="margin-top: 5%;" v-for="item in get ":key="index" >
			<text>用户名：{{item.phone||item.name}}</text>
			<text>内容：{{item.content}}</text>
		</view> -->
			<list-scroll>
				<list-card :list="list" :item="item" v-for="item in item" :key="item"   :cx="true"></list-card>
			</list-scroll>

		</view>

		
		<view v-else style="text-align: center; margin-top: 8%; font-size: 30rpx;">亲！没有查询到用户被举报！
			<image src="../../static/img/空.png" v-if="caxun" mode="aspectFit" style="margin-top: 2%;"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				InputBottom: 0,
				index: 0,
				picker: ['手机号码', '微信号', '支付宝号'],
				pay: ['phone', 'wx', 'zfb'],
				info: "",
				item: [],
				caxun: false,
 
				isvip: "", //是否会员
			}
		},
		onLoad(option) {
			console.log(option.vip);
			this.isvip = option.vip
		},
		components: {

		},
		methods: {
			PickerChange(e) {
				this.index = e.detail.value
			},
			cx() {			 
				if(!parseInt(this.isvip)){
					uni.showModal({
					    title: '提示',
					    content: '当前不是会员不能使用该功能',
							confirmText:"充值会员",
					    success: function (res) {
					        if (res.confirm) {
					           uni.navigateTo({
					           	url:"../vip/vip"
					           })
					        }  
					    }
					});
				}else{
					uni.showLoading()
				this.init()
				}
				
				
			},
			onPullDownRefresh() {
				if (this.isvip) {
					if (this.pay[this.index] && this.info) {
						this.init()
					}
					setTimeout(() => {
						uni.stopPullDownRefresh()
					}, 1000)
				}
			},
			init() {
				let that = this;
				uniCloud.callFunction({
					name: "Inquirejubao",
					data: {
						type: this.pay[this.index],
						info: this.info
					},
					success: (res) => {
						that.item = res.result.data;
						console.log(that.item)
						if(that.item.length){
							that.caxun=false;
					
						}
						else{
							that.caxun=true;
						}uni.hideLoading()
						
						if (that.item.length) {
							that.caxun = false;
						} else {
							that.caxun = true;
						}
						uni.hideLoading()
						uni.stopPullDownRefresh()
						console.log(res.result.data);

					},
					fail: (err) => {
						console.log(err);
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.wen {
		display: flex;
		justify-content: center;
		align-items: center;
		margin: 2% 0%;

	}
</style>
